.class public Lcom/htc/android/footprints/utils/voice/VoicePlayer;
.super Ljava/lang/Object;
.source "VoicePlayer.java"


# annotations
.annotation system Ldalvik/annotation/MemberClasses;
    value = {
        Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;
    }
.end annotation


# static fields
.field public static final STATE_ERROR:I = -0x1

.field public static final STATE_IDLE:I = 0x1

.field public static final STATE_PAUSE:I = 0x3

.field public static final STATE_PLAYING:I = 0x2

.field public static final STATE_PLAY_COMPLETE:I = 0xa

.field private static final TAG:Ljava/lang/String; = "VoicePlayer"


# instance fields
.field completelistener:Landroid/media/MediaPlayer$OnCompletionListener;

.field errorListener:Landroid/media/MediaPlayer$OnErrorListener;

.field public mCurrentState:I

.field private mHandler:Landroid/os/Handler;

.field private mIsInitialized:Z

.field private mMediaPlayer:Landroid/media/MediaPlayer;

.field private mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;


# direct methods
.method public constructor <init>()V
    .locals 1

    .prologue
    .line 26
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 14
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    .line 24
    const/4 v0, 0x1

    iput v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mCurrentState:I

    .line 114
    new-instance v0, Lcom/htc/android/footprints/utils/voice/VoicePlayer$1;

    invoke-direct {v0, p0}, Lcom/htc/android/footprints/utils/voice/VoicePlayer$1;-><init>(Lcom/htc/android/footprints/utils/voice/VoicePlayer;)V

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->errorListener:Landroid/media/MediaPlayer$OnErrorListener;

    .line 134
    new-instance v0, Lcom/htc/android/footprints/utils/voice/VoicePlayer$2;

    invoke-direct {v0, p0}, Lcom/htc/android/footprints/utils/voice/VoicePlayer$2;-><init>(Lcom/htc/android/footprints/utils/voice/VoicePlayer;)V

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->completelistener:Landroid/media/MediaPlayer$OnCompletionListener;

    .line 27
    new-instance v0, Landroid/media/MediaPlayer;

    invoke-direct {v0}, Landroid/media/MediaPlayer;-><init>()V

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    .line 28
    return-void
.end method

.method static synthetic access$002(Lcom/htc/android/footprints/utils/voice/VoicePlayer;Z)Z
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 10
    iput-boolean p1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    return p1
.end method

.method static synthetic access$100(Lcom/htc/android/footprints/utils/voice/VoicePlayer;)Landroid/media/MediaPlayer;
    .locals 1
    .parameter "x0"

    .prologue
    .line 10
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    return-object v0
.end method

.method static synthetic access$102(Lcom/htc/android/footprints/utils/voice/VoicePlayer;Landroid/media/MediaPlayer;)Landroid/media/MediaPlayer;
    .locals 0
    .parameter "x0"
    .parameter "x1"

    .prologue
    .line 10
    iput-object p1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    return-object p1
.end method

.method static synthetic access$200(Lcom/htc/android/footprints/utils/voice/VoicePlayer;)Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;
    .locals 1
    .parameter "x0"

    .prologue
    .line 10
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;

    return-object v0
.end method

.method private setState(I)V
    .locals 1
    .parameter "state"

    .prologue
    .line 110
    iput p1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mCurrentState:I

    .line 111
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;

    invoke-interface {v0, p1}, Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;->OnPlayerStateChanged(I)V

    .line 112
    return-void
.end method


# virtual methods
.method public closeVoicePlayer()V
    .locals 1

    .prologue
    .line 43
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    if-eqz v0, :cond_0

    .line 44
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->stop()V

    .line 45
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->release()V

    .line 46
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    .line 49
    :cond_0
    return-void
.end method

.method public duration()J
    .locals 2

    .prologue
    .line 97
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->getDuration()I

    move-result v0

    int-to-long v0, v0

    return-wide v0
.end method

.method public isInitialized()Z
    .locals 1

    .prologue
    .line 31
    iget-boolean v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    return v0
.end method

.method public isPlaying()Z
    .locals 1

    .prologue
    .line 93
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->isPlaying()Z

    move-result v0

    return v0
.end method

.method public pause()V
    .locals 1

    .prologue
    .line 88
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->pause()V

    .line 89
    const/4 v0, 0x3

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->setState(I)V

    .line 90
    return-void
.end method

.method public position()J
    .locals 2

    .prologue
    .line 101
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->getCurrentPosition()I

    move-result v0

    int-to-long v0, v0

    return-wide v0
.end method

.method public preparePlay(Ljava/lang/String;)V
    .locals 0
    .parameter "voicepath"

    .prologue
    .line 35
    invoke-virtual {p0, p1}, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->setDataSource(Ljava/lang/String;)V

    .line 36
    return-void
.end method

.method public restoreState(Landroid/os/Bundle;)V
    .locals 0
    .parameter "recorderState"

    .prologue
    .line 39
    return-void
.end method

.method public seek(J)J
    .locals 2
    .parameter "whereto"

    .prologue
    .line 105
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    long-to-int v1, p1

    invoke-virtual {v0, v1}, Landroid/media/MediaPlayer;->seekTo(I)V

    .line 106
    return-wide p1
.end method

.method public setDataSource(Ljava/lang/String;)V
    .locals 5
    .parameter "path"

    .prologue
    const/4 v4, 0x0

    const/4 v3, -0x1

    .line 53
    :try_start_0
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->reset()V

    .line 54
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1, p1}, Landroid/media/MediaPlayer;->setDataSource(Ljava/lang/String;)V

    .line 55
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->completelistener:Landroid/media/MediaPlayer$OnCompletionListener;

    invoke-virtual {v1, v2}, Landroid/media/MediaPlayer;->setOnCompletionListener(Landroid/media/MediaPlayer$OnCompletionListener;)V

    .line 56
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    iget-object v2, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->errorListener:Landroid/media/MediaPlayer$OnErrorListener;

    invoke-virtual {v1, v2}, Landroid/media/MediaPlayer;->setOnErrorListener(Landroid/media/MediaPlayer$OnErrorListener;)V

    .line 57
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v1}, Landroid/media/MediaPlayer;->prepare()V
    :try_end_0
    .catch Ljava/io/IOException; {:try_start_0 .. :try_end_0} :catch_0
    .catch Ljava/lang/IllegalArgumentException; {:try_start_0 .. :try_end_0} :catch_1

    .line 69
    const/4 v1, 0x1

    iput-boolean v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    .line 70
    :goto_0
    return-void

    .line 58
    :catch_0
    move-exception v1

    move-object v0, v1

    .line 59
    .local v0, ex:Ljava/io/IOException;
    iput-boolean v4, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    .line 60
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;

    invoke-interface {v1, v3}, Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;->OnError(I)V

    goto :goto_0

    .line 62
    .end local v0           #ex:Ljava/io/IOException;
    :catch_1
    move-exception v1

    move-object v0, v1

    .line 63
    .local v0, ex:Ljava/lang/IllegalArgumentException;
    iput-boolean v4, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    .line 64
    iget-object v1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;

    invoke-interface {v1, v3}, Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;->OnError(I)V

    goto :goto_0
.end method

.method public setHandler(Landroid/os/Handler;)V
    .locals 0
    .parameter "handler"

    .prologue
    .line 73
    iput-object p1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mHandler:Landroid/os/Handler;

    .line 74
    return-void
.end method

.method public setPlayerStateChangedListener(Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;)V
    .locals 0
    .parameter "cb"

    .prologue
    .line 143
    if-eqz p1, :cond_0

    iput-object p1, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mOnPlayerStateChangedListener:Lcom/htc/android/footprints/utils/voice/VoicePlayer$OnPlayerStateChangedListener;

    .line 144
    :cond_0
    return-void
.end method

.method public start()V
    .locals 1

    .prologue
    .line 77
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->start()V

    .line 78
    const/4 v0, 0x2

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->setState(I)V

    .line 79
    return-void
.end method

.method public stop()V
    .locals 1

    .prologue
    .line 82
    iget-object v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mMediaPlayer:Landroid/media/MediaPlayer;

    invoke-virtual {v0}, Landroid/media/MediaPlayer;->reset()V

    .line 83
    const/4 v0, 0x0

    iput-boolean v0, p0, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->mIsInitialized:Z

    .line 84
    const/4 v0, 0x1

    invoke-direct {p0, v0}, Lcom/htc/android/footprints/utils/voice/VoicePlayer;->setState(I)V

    .line 85
    return-void
.end method
